package vooga.behaviors;

import java.awt.geom.Rectangle2D;

import vooga.entities.Entity;


/**
 * Move Behavior
 * 
 * created 11-19
 * @author Ben Shelton
 * @author Congyi Wu
 */
public class MoveBehavior extends AbstractBehavior
{
//    private Vector myVelocity;
    private Rectangle2D myBounds;

    public MoveBehavior (Rectangle2D bounds)
    {
    	myBounds = bounds;
    }
    
    public MoveBehavior ()
    {
    	this(null);
    }
//    public MoveBehavior (Vector velocity)
//    {
//        this(velocity, null);
//    }
    
//    public MoveBehavior (Vector velocity, Rectangle2D bounds)
//    {
//        myVelocity = velocity;
//        myBounds = bounds;
//    }

    
    
//    public Vector getVelocity()
//    {
//    	return myVelocity;
//    }
//    
//    public void setVelocity(Vector velocity) {
//    	myVelocity = velocity;
//    }
//    
//    public void setXYVelocity(double dx, double dy) {
//    	myVelocity.setXYChange(dx, dy);
//    }
//    
//    public void setXVelocity(double xVel) {
//    	myVelocity.setXChange(xVel);
//    }
//    
//    public void setYVelocity(double yVel) {
//    	myVelocity.setYChange(yVel);
//    }
    
    /**
     * move one step, making sure not to cross bounds if given
     */
    public void step (Entity target)
    {
        target.translate(target.getVelocity().getXChange(), target.getVelocity().getYChange());
        if(myBounds != null)
        	{
        		if(target.getLeft() < myBounds.getMinX())
        			target.setLeft(myBounds.getMinX());

        		else if(target.getRight() > myBounds.getMaxX())
        			target.setRight(myBounds.getMaxX());
        		
        		if(target.getTop() < myBounds.getMinY())
        			target.setTop(myBounds.getMinY());
        		
        		else if(target.getBottom() > myBounds.getMaxY())
        			target.setBottom(myBounds.getMaxY());
       		
        	}
    }
}
